<?php

/*
 * Copyright by Sygma Media Inovasi Ω2013
 * 
 * Lead Programmer : Sony K Wibisono,S.Si,M.T.I
 * E-mail : sony@sonywibisono.com
 * 
 * Designer : Mr. Agus
 * 
 */
class Groups {
    var $id;
    var $group_name;
    var $group_desc;


    function open(){
        global $db;
        $sql="select * from groups where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->group_name=$group_name;
            $this->group_desc=$group_desc;

        }
    }

    function openAll(){
        $sql="select * from groups order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into groups values (null,'{$this->group_name}',
        '{$this->group_desc}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update groups set group_name='{$this->group_name}',
        group_desc='{$this->group_desc}' where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from groups where id=".$this->id;
        $db->query($sql);
    }

}
?>
